<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ include file="../include/header.jsp" %>    
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Member Detail</title>
<script type="text/javascript">
function add_favor_member(userid){
	if(confirm(userid+"님을 관심회원에 등록하시겠습니까?")){
		param = "favorid="+userid;
		$.ajax({
			type:"post",
			url:"${path}/member/add_favor_member.do",
			data:param,
			success:function(msg){
				alert(msg);
			}			
		});		
	}
}
</script>
<!--  my page -->
<c:if test="${sessionScope.userid == map.dto.userid }">
<script type="text/javascript">
$(document).ready(function(){
	my_info();	
});
function my_info(){
	$.ajax({
		type:"post",
		url:"${path}/member/myinfo.do",
		success:function(msg){
			$("#div_myinfo").html(msg);
		}
	});	
}

function my_member_del(){
	if(confirm("삭제하시겠습니까?")){
		var selected_member = $("#select_my_member").val();
		var param = "favorid="+selected_member;
		$.ajax({
			type:"post",
			url:"${path}/member/del_favor_member.do",
			data:param,
			success:function(){
				my_info();
			}
		});	
	}	
}

function my_recipe_del(){
	if(confirm("삭제하시겠습니까?")){
		var selected_recipe = $("#select_my_recipe").val();
		var param = "idx="+selected_recipe;
		$.ajax({
			type:"post",
			url:"${path}/member/del_favor_recipe.do",
			data:param,
			success:function(){
				my_info();
			}
		});	
	}		
}

function my_member_detail(){
	var selected_member = $("#select_my_member").val();
	if(selected_member != null){
		location.href="${path}/member/memberDetail.do?userid="+selected_member;
	}
}

function my_recipe_detail(){
	var recipe_idx = $("#select_my_recipe").val();
	if(recipe_idx != null){
		location.href="${path}/recipe/recipe_detail.do?idx="+recipe_idx;
	}	
}
</script>
</c:if>

</head>
<body>
	<h4>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
		<img alt="${map.dto.level }" src="${path }/images/lv/${map.dto.level}.gif">
		${map.dto.userid } 님의 주방입니다
		<c:if test="${sessionScope.userid != map.dto.userid }">
		<input type="button" value="관심회원추가" onclick="add_favor_member('${map.dto.userid}')">	
		</c:if>	
		
		<c:if test="${(sessionScope.level =='1' || sessionScope.level =='0') && (sessionScope.userid == map.dto.userid) }">
		<a href="${path}/class1/class1_write.do">[강좌 개설]</a>
		</c:if>
	</h4>	
	<table style="border:solid black; width: 900px; margin: 0 auto;" border="1">
	<tr>
		<td rowspan="5" colspan="1" style="height: 200px; width: 200px;">
			<c:if test="${map.dto.image == null }">
			<img alt="default.jpg" 
			src="${path }/images/member/default.jpg" style="height: 200px; width: 200px;">
			</c:if>		
			<c:if test="${map.dto.image != null }">
			<img alt="${map.dto.image }" 
			src="${path }/images/member/${map.dto.userid}/${map.dto.image}" style="height: 200px; width: 200px;">
			</c:if>
		</td>
		<th width="80">ID</th>
		<th>${map.dto.userid }</th>
		<th>Name</th>
		<th>${map.dto.name }</th>
		<th rowspan="6" width="1" style="background-color: black;"></th>
		<th rowspan="2">전문분야</th>
		<th colspan="4" rowspan="2">${map.dto.major}</th>
	</tr>
	<tr>
		<th>Level</th>
		<th colspan="2">
			<img alt="${map.dto.level }.jpg" src="${path }/images/lv/${map.dto.level}.gif">
			<c:choose>
					<c:when test="${map.dto.level == 0}">Admin</c:when>
					<c:when test="${map.dto.level == 1}">마스터쉐프</c:when>
					<c:when test="${map.dto.level == 2}">쉐프</c:when>
					<c:when test="${map.dto.level == 3}">선임요리사</c:when>
					<c:when test="${map.dto.level == 4}">견습요리사</c:when>
					<c:when test="${map.dto.level == 5}">주방보조</c:when>				
			</c:choose>
		</th>
		<td>
			${map.dto.point }점
		</td>	

	</tr>
	<tr>
		<td>E-Mail</td>
		<td colspan="3">${map.dto.email }</td>
				<th>평점 평균</th>
		<th>[${map.dto.rate_avg }]
			<c:forEach begin="1" end="${map.dto.rate_avg }" >
					★
			</c:forEach>
		</th>
		<td rowspan="4" width="5"></td>			
		<th>평점 합계</th>
		<th>${map.dto.rate_sum }</th>

	</tr>
	<tr>
		<td>Mobile</td>
		<td colspan="3">
			${map.dto.hp }
		</td>
		
			<td>나의 레시피</td>
			<td>
			<a style="font-weight:bold; margin:0 auto;  " href="${path}/recipe/recipe_list.do?search_option=userid&search=${map.dto.userid }">
			${map.dto.recipe_cnt }개</a>
			</td>
			
			<td>나의 댓글</td>
			<td>${map.dto.cmt_cnt }</td>

	</tr>
	<tr>
		<td>Profile</td>
			<td colspan="3">
				${map.dto.profile }
			</td>
			<th >나를 찜한 회원</th>
			<th >${map.dto.favor_me_cnt }명</th>
			
			<th >레시피 찜 횟수</th>
			<th >${map.dto.favor_rcp_cnt}회</th>
	</tr>
	</table>
<!-- TOP 3 -->
	<div id="div_myinfo"></div>	
	<hr  style="border: solid black;">
	<table border="1" style="border:solid black; width: 900px; margin: 0 auto;">
		<tr style="background-color: black; color: white;">
			<th colspan="2" width="33%">최근 레시피</th>
			<th rowspan="4"></th>
			<th colspan="2" width="33%">평점상위 레시피</th>
			<th rowspan="4"></th>
			<th colspan="2" width="33%">미 정</th>
		</tr>
		<c:forEach  begin="0" end="2" step="1" var="row">
		<tr>
			<th>${map.list_date[row].post_date }</th>
			<th><a href="${path}/recipe/recipe_detail.do?idx=${map.list_date[row].idx }">
			${map.list_date[row].subject }</a>
			</th>
			
			<th>${map.list_rate[row].rate }</th>
			<th><a href="${path}/recipe/recipe_detail.do?idx=${map.list_rate[row].idx }">
			${map.list_rate[row].subject }</a>
			</th>
			
			<th>${map.list_class[row].class_date }</th>
			<th>${map.list_class[row].subject }</th>
		</tr>
		</c:forEach>
	</table>	

	
</body>
</html>